Conversion from gray code to binary code



March 12, 1968 MAO c. WANG CONVERSION FROM GRAY CODE TO BINARY CODEFiled Oct. 15, 1964 I i i K W1 W2 a l/n fl/H M: 1 1 0 1 Z 3 6 Q w 0 W01/. 60 W 0 wlw r 1/ 6 0 M M V 1 4 5 G T 1 5 0 w 0 a INVENTOR. M40 6,1444/1/47 United States Patent M 3,373,421 CONVERSION FROM GRAY CODE T0BINARY CODE Mao C. Wang, Camden, N.J., assignor to Radio Corporation ofAmerica, a corporation of Delaware Filed Oct. 15, 1964, Ser. No. 404,1174 Claims. (Cl. 340-347) ABSTRACT OF THE DISCLOSURE A Gray-to-binary codeconverter includes N bit input terminals connected through respectivesignal paths to an equal number of output terminals. The signal pathsinclude tiers of exclusive or gates, the number of tiers being equal tolog N where N is a number of bits equal to an integral power of two.Each tier includes a number equal to N-N/Z of exclusive or gates havinginputs coupled to respective low-order signal paths, where t is thenumber of the particular tier. Each gate also has an input coupled to arespective signal path N 2 bits positions removed in the higher orderdirection.

General This invention relates to converters for converting any numberrepresented in the Gray or reflected code to the corresponding numberrepresented in the conventional binary code.

Equivalent quantities in the decimal, Gray and binary codes are given inthe following table:

The Gray or reflected code is a code in which each word, made up of manydigits, diifers in one digit only from adjacent words in the countingsequence. This characteristic of the Gray or reflected code makes itespecially useful and reliable in connection with certain apparatus andprocesses in which continuously varying quantities are encoded. Forexample, an analog-to-digital converter is an important unit used totranslate a continuously varying signal into a binary-coded signal. Whenthe varying quantity is encoded in the Gray code, a failure to make aone-digit change results in a Gray coded word that is in error by onlyone unit in the counting sequence. The maximum sampling error in theGray code is one counting unit. By contrast, a failure to make any oneof several digit changes in a binary coded word may result in an errorof many units in the counting sequence. A sampling error in the binarycode may represent an error of many counting units. However, the Graycode is unsuited for use in a computer in the performance of the usualarithmetic manipulations. Therefore, a converter is needed to translatenumbers in the Gray or reflected code to the corresponding numbers inthe conventional binary code.

It is a general object of this invention to provide an improvedconverter for converting any number in the Gray or reflected code to acorresponding number in the conventional binary code, the converterbeing character- 3,373,421 Patented Mar. 12, 1968 ized in being simple,economical to manufacture, and rapid in operation.

According to an example of the invention, a Gray-tobinary converterincludes N bit input terminals connected through respective signal pathsto an equal number of output terminals. The signal paths include tiersof exclusive or gates, the number of tiers being equal to l0g N where Nis a number of bits equal to an integral power of two. Each tierincludes a number equal to N-N/Z of exclusive or gates having inputscoupled to respective low-order signal paths, where t is the number ofthe particular tier. Each gate also has an input coupled to a respectivesignal path N/2 bit positions removed in the higher order direction. Theconversion of a Gray code number having N bits to the correspondingbinary code number is accomplished in the time of log; N transistorcircuit stage delays.

In the drawing:

FIG. 1 is a schematic diagram of a code converter constructed accordingto the teachings of the invention; and

FIG. 2 is a circuit diagram of an exclusive or gate for use in theconverter of FIG. 1.

Referring now in greater detail to the drawing, there is shown a codeconverter including Gray code signal bit input terminals G through G foreight bits of an input word. The input terminals are connected throughrespective signal paths to respective binary code signal bit outputterminals 2 through 2 There are three tiers of exclusive or gatesarranged in the signal paths. The number of necessary tiers of gates isdetermined by the number of bits in the words to be converted. In thepresent example, the number of bits N is equal to eight, and the numberof tiers is equal to log N, or log 8, which is equal to 3.

The first tier of gates includes four gates 10, 11, 12 and 13 located inthe signal paths of the four lowestorder bits. Each of the gates in thefirst tier has also an input connected to a signal path for ahigher-order bit four bit positions removed to the left. The second tierof gates includes six gates 20' through 25 located in the six signalpaths for the six lowest-order bits. Each gate in the second tier alsohas an input coupled to a respective signal path for a higher-order bittwo bit positions removed to the left. The third tier of gates includesseven gates 30 through 36 located in the seven lowest-order signalpaths. Each gate in the third tier also includes an input connected tothe next-higher-order signal path.

The number of gates in any. tier is given by NN/2 where N is the numberof bits and t is the number of the tier counting from the input end. Oneinput of each gate is coupled to the respective low-order signal path.The other input of each gate is coupled to arespective signal pathremoved or offset in the higher order direction by N/Z bit positions.The values in the present example where N=8 are as follows:

The formulas may be used to design a converter for Gray coded numbershaving any desired number N of bits. It is first necessary to determinethe number of tiers equal to log N. Examples are as follows:

3 If the desired number of bits falls between numbers which are integralpowers of 2, the higher number N is used in determining the number oftiers, and the number of gates in each tier. However, unused high ordersignal paths, and gates coupled thereto, may be omitted from theconverter actually constructed.

FIG. 2 illustrates an exclusive or gate useful in the converter of FIG.1 at the places of each of the or gate symbols in the diagram. Theexclusive or gate of FIG. 2 includes input terminals I and 1 eachconnected to a respective base electrode of transistors Q and Q Theinput terminals I and 1 are also connected through resistors 41 and 412to emitter electrodes of respective transistors Q and Q The emitter ofeach transistor is connected through a respective parallel circuit 43',44, each including a diode and a resistor, to the negative terminal -Vof a .source of unidirectional bias potential (not shown). Thecollectors of transistors Q and Q are connected together to an outputterminal 45.

In operation, the exclusive or gate in FIG. 2 provides an output signalon its output terminal 45 solely when there is an input signal appliedto one or the other, but not both, of the input terminals I and I In theabsence of inputs to terminals I and 1 the transistors Q and Q arenonconducting and no output signal appears at output terminal 45. When apositive signal is applied solely to input terminal I the transistor Qis rendered conductive by the positive going signal on its emitterelectrode, and the transistor Q is kept cut off by the positive signalon its base electrode. The conduction in transistor Q causes an outputto appear on the common output terminal 45. The same output signalappears when a positive going input signal is applied solely to inputterminal I If positive going signals are applied to both of the inputterminals I and I both transistors remain cut off because the baseelectrodes of both transistors receive potentials more positive than thepotentials applied to their emitter electrodes.

The operation of the converter of FIG. 1 will now be described by givingan example in which a particular Gray coded number is converted to thecorresponding binary coded number. In the numeric example, the Gray-'coded number applied to the input terminals G through G is 10111011,where the most significant digit is at the left and the leastsignificant digit is at the right. Each of the exclusive or gates 10,11, 12 and 13 in the first tier performs the exclusive or function onthe two bit signals applied to its inputs to produce the first resultingnumber 10110000. The outputs of gates 10, 11 and 13 are Os because bothof their inputs are ls. The output of gate 12 is 0 because both of itsinputs are Us The gates 20 through 25 in the second tier of gates eachresponds to its two inputs to produce a second resulting number10011100. Gates 20, 21 and 25 produce 0 outputs because their inputs arethe same. Gates 27;, 23 and 24 produce 1 outputs because their twoinputs are different.

Finally, the gates 30 through 36 of the third tier produce on outputterminals 2 through 2 the number 11010010, which is the binary-codedequivalent of the number in the Gray code applied to the input terminalsG through 6.

The conversion of an eight-bit Gray-coded number to the correspondingbinary coded number is accomplished in the time of only three transistorcircuit stage delays because there are only three tiers of exclusive orgate transistor circuits. If, for example, the converter is intended forconverting numbers having sixteen bits, the converter will include fourtiers of gates and will perform the conversion in four stage delays. Thenumber of stage delays is equal to the number of tiers of gates in theconverter. The converter is one in which all the bits of a number to beconverted are applied in parallel to the 4 converter. The output bits ofthe binary-coded number are also available in parallel.

The input connections of the gates 10 through 13 of the first tierresult, in efiect, in the performance of the exclusive or function onrespective bits of the input Gray coded word, and corresponding bits ofthe same word after it is shifted four places to the right with adropping of the four lowest order bits and the insertion of 0s in thefour most significant bit positions. Similarly, the operation of thesecond tier of gates results in the performance of the exclusive orfunction on bits of the result from the first tier and bits of theresult shifted two places to the right. Finally, the gates of the thirdtier perform the exclusive or function on bits of the result from thesecond tier of gates and the result shifted one place to the right.Therefore, the code conversion process performed by the system of FIG. 1may also be performed by different means capable of shifting words tothe right and performing the exclusive or function on respective bits ofthe unshifted word and the shifted word.

What is claimed is:

1. A converter for converting a number from the Gray code to the binarycode, the number having not more than N digits, where N is any integralpower of 2, comprising not more than N signal paths between Gray codeinput terminals and respective binary code output terminals, said pathsincluding exclusive or gates arranged in log N tiers,

each of said tiers including a number equal to N N 2 of exclusive orgates having inputs coupled to respective low-order signal paths, wheret is the number of the particular tier,

each gate also having an input coupled to a respective signal path N 2bit positions removed in the higher order direction.

2. A converter for converting a number from the Gray code to the binarycode, comprising N signal paths between Gray code input terminals andrespective binary code output terminals, N being an integral power of 2,said paths including exclusive or gates arranged in log N tiers,

each of said tiers including a number equal to N -N/ 2 of exclusive orgates having inputs coupled to respective low-order signal paths, wheret is the number of the particular tier,

each gate also having an input coupled to a respective signal path N/Zbit positions removed in the higher order direction.

3. A converter for converting a number from the Gray code to the binarycode, the number having not more than N digits, and having more than N-1 digits, where N is any integral power of 2, comprising N inputterminals for digits of the Gray coded number,

N output terminals for digits of the corresponding binary coded number,

N signal paths between said input terminals and respec tive outputterminals including exclusive or gates arranged in a number equal to logN of successive tiers,

each of said tiers including a number equal to N-N/Z of exclusive orgates having inputs coupled to respective low-order signal paths, wheret is the number of the particular tier,

each gate also having an input coupled to a respective signal path N/2bit positions removed in the higher order direction.

4. A converter for converting a number from the Gray code to the binarycode, comprising N input terminals for digits of the Gray coded number,

N being an integral power of 2,

N output terminals for digits of the corresponding binary coded number,

N signal paths between said input terminals and respective outputterminals including exclusive or gates arranged in a number equal to logN of successive tiers,

each of said tiers including a number equal to N N/2 of exclusive orgates having inputs coupled to respective low-order signal paths, wheret is the number of the particular tier,

each gate also having an input coupled to a respective order direction.

References Cited UNITED STATES PATENTS Wood 30788.5 Crowell 235-155Cadden et a1. 340347 Moss 340-347 MAYNARD R. WILBUR, Primary Examiner.signal path N 2 bit positions removed in the higher 10 H. L. BRYAN, W.J. KOPACZ, Assistant Examiners.

